#ifndef DATAANALYZER_H
#define DATAANALYZER_H

#include <QtGui/QMainWindow>
#include <QComboBox>
#include <QLineEdit>
#include <QSettings>
#include <QMap>
#include <QLabel>
#include <QSharedPointer>

#include "ui_dataanalyzer.h"
#include "tablemodel.h"
#include "byteitemdelegate.h"
#include "viewmode.h"

#include "crc_info.h"


class DataAnalyzer : public QMainWindow
{
	Q_OBJECT

public:
	DataAnalyzer(QWidget *parent = 0, Qt::WFlags flags = 0);
	~DataAnalyzer();


public slots:
	void on_actionOpen_triggered();
	void on_actionCRCconfig_triggered();
	void on_tableViewDataSelModel_selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );

	//void on_comboboxViewMode_currentIndexChanged(int index);

	void on_actionViewModelDecimal_triggered();
	void on_actionViewModelHEX_triggered();
	void on_actionViewModelBinary_triggered();
	void on_actionViewModelBinaryInverted_triggered();
	void on_actionViewModelSymbol_triggered();
	void on_actionViewModelBitPixel_triggered();

	void on_ViewModeChanged(ViewMode vm);

signals:
	void viewMode_Changed(ViewMode vm);

protected:
	virtual void selectionChanged( const QItemSelection & selected, const QItemSelection & deselected );

private:
	void openFile(const QString & filename, int splitsize = -1);

	void writeSettings();
	void readSettings();

	void recreateCRCLabels();
private:
	Ui::DataAnalyzerClass ui;
	QString m_filename;
	DPOTableModel _model;
	ByteItemDelegate _byteDelegate;

	//QComboBox * _cmbViewMode;

	CRC_CONTAINER _crc_infos;
	QMap<QString, QPair< QSharedPointer<QLabel>, QSharedPointer<QLabel> > > _CRC_dynamic_labels;
};

#endif // DATAANALYZER_H
